﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GHRMS.BLL;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PR_SalaryEmployee : System.Web.UI.UserControl
    {
        private object _dataItem = null;
        EmployeeBLL empBll = new EmployeeBLL();

        //ReadOnly property.
        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }
        protected bool IsUserControlPostBack
        {
            get
            {
                return this.ViewState["IsUserControlPostBack"] != null;
            }
        }
        //Initializing the new variable updating ViewState data.
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);

            if (!IsUserControlPostBack)
            {

                this.ViewState.Add("IsUserControlPostBack", true);
            }

            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    lblID.Text = DataBinder.Eval(DataItem, "emp_seq").ToString();
                    txtSalary.Text = DataBinder.Eval(DataItem, "salary").ToString();

                    this.btnUpdate.Visible = true;
                }
                else
                {
                    this.btnUpdate.Visible = false;
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                empBll.UpdateSingleField(Convert.ToInt32(lblID.Text), "salary", txtSalary.Text, new SsMng().EmpSeqI);
            }
            catch (Exception ex)
            {

            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}